---
artifact: {{ .ModuleName }}/vertical-pod-autoscaler-artifact
from: {{ .Images.BASE_GOLANG_19_ALPINE }}
git:
- add: /{{ $.ModulePath }}/modules/302-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
  to: /patches
  stageDependencies:
    install:
      - '**/*'
shell:
  install:
    - apk add --no-cache git
    - mkdir -p /src
    - cd /src
    - git clone --depth 1 -b vertical-pod-autoscaler-0.14.0 {{ $.SOURCE_REPO }}/kubernetes/autoscaler.git .
    - find /patches -name '*.patch' -exec git apply {} \;
    - export GO_VERSION=${GOLANG_VERSION}
    - export GOPROXY={{ $.GOPROXY }}
    - cd vertical-pod-autoscaler/pkg/admission-controller
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o /admission-controller
    - chown 64535:64535 /admission-controller
    - chmod 0700 /admission-controller
    - cd ../../../vertical-pod-autoscaler/pkg/recommender
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o /recommender
    - chown 64535:64535 /recommender
    - chmod 0700 /recommender
    - cd ../../../vertical-pod-autoscaler/pkg/updater
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o /updater
    - chown 64535:64535 /updater
    - chmod 0700 /updater
